package com.haynes.meetxiaohai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haynes.meetxiaohai.common.CustomException;
import com.haynes.meetxiaohai.entity.User;
import com.haynes.meetxiaohai.mapper.UserMapper;
import com.haynes.meetxiaohai.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author Haynes
 * @Date 2023/3/23 16:12
 * @PackageName:com.haynes.reggie.service.impl
 * @ClassName: UserServiceImpl
 */
@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User login(User user) {
        LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
        userLambdaQueryWrapper.eq(User::getStatus,1);
        userLambdaQueryWrapper.eq(User::getPhone,user.getPhone());
        User loginUser = this.getOne(userLambdaQueryWrapper);
        if (loginUser==null){
            throw new CustomException("用户不存在~");
        }
        return loginUser;
    }
}
